package cn.wolfcode.web.controller;


import cn.wolfcode.domain.MessageBoardZrh;
import cn.wolfcode.domain.MessageReplyZrh;
import cn.wolfcode.service.IMessageBoardZrhService;
import cn.wolfcode.service.IMessageReplyZrhService;
import cn.wolfcode.util.RequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/messageReplyZrh")
public class MessageReplyZrhController {

    @Autowired
    private IMessageReplyZrhService messageReplyZrhService;
    @Autowired
    private IMessageBoardZrhService messageBoardZrhService;
    @RequestMapping("/reply")
    public String reply(Long id,Model model){
        List<MessageReplyZrh> messageReplyZrh = messageReplyZrhService.selectByBoardId(id);
        MessageBoardZrh messageBoardZrh = messageBoardZrhService.get(id);
        model.addAttribute("messageBoardZrh",messageBoardZrh);
        model.addAttribute("messageReplyZrh",messageReplyZrh);
        return "message/reply";
    }

    @RequiredPermission(name="留言详情删除",expression="messageReplyZrh:delete")
    @RequestMapping("/delete")
    public String delete(Long id) {
        if (id != null) {
           messageReplyZrhService.delete(id);
        }
        return "redirect:/messageReplyZrh/list";
    }


}
